import cn.itcast.domain.Account;
import cn.itcast.service.AccountService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class Account增删改查测试 {
    @Test
    public void findAll(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        AccountService accountService = context.getBean(AccountService.class);
        List<Account> all = accountService.findAll();
        System.out.println("all = " + all);
    }

    @Test
    public void delete (){
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        AccountService accountService = applicationContext.getBean(AccountService.class);
        accountService.delete(2);

    }
    @Test
    public void uodate (){
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        AccountService accountService = applicationContext.getBean(AccountService.class);
        Account account = new Account(3, "乐乐", 15000.00);
        accountService.update(account);

    }

    @Test
    public void add (){
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        AccountService accountService = applicationContext.getBean(AccountService.class);
        Account account = new Account(9, "乐吧", 15000.00);
        accountService.add(account);

    }

}
